import 'package:catsao/entity/news_item_entity.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

import 'package:flutter_html/flutter_html.dart';

class NewsDetailPage extends StatefulWidget {
  final NewsItemEntity newsItem;

  NewsDetailPage({Key key, this.newsItem}) : super(key: key);

  @override
  _NewsDetailPage createState() => new _NewsDetailPage();
}

class _NewsDetailPage extends State<NewsDetailPage> {
  bool _checkboxSelected = false;

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      resizeToAvoidBottomInset: false,
      appBar: new AppBar(
        title: new Text(widget.newsItem.title),
      ),
      body: Center(
          child: Stack(children: <Widget>[
        Flex(
          direction: Axis.vertical,
          children: <Widget>[
            Expanded(
              flex: 12,
              child:
                  ListView(
                    children: [
                      Html(data:widget.newsItem.content)
                    ],
                  )


            //   WebView(
            //     initialUrl: widget.newsItem.url,),


            ),
            Expanded(
                child: Container(
              child: Row(
                children: <Widget>[
                  Padding(
                    padding: const EdgeInsets.only(left: 10.0),
                    child: ButtonTheme(
                      minWidth: 180.0,
                      height: 30.0,
                      child: FlatButton.icon(
                        color: Color(0xFFeee7e5),
                        icon: Icon(Icons.border_color),
                        label: Text("说两句"),
                        shape: RoundedRectangleBorder(
                            side: BorderSide.none,
                            borderRadius: BorderRadius.all(Radius.circular(50))),
                        onPressed: () {
                          showModalBottomSheet(
                            context: context,
                            shape: RoundedRectangleBorder(
                              borderRadius: BorderRadius.only(
                                  topLeft: Radius.circular(10.0),
                                  topRight: Radius.circular(10.0)),
                            ),
                            builder: (BuildContext context) {
                              return StatefulBuilder(
                                  builder: (context1, setBottomSheetState) {
                                return Container(
                                  child: Column(
                                    children: <Widget>[
                                      Padding(
                                        padding: const EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 0),
                                        child: TextField(
                                          autofocus: true,
                                          maxLines: 4,
                                          style: TextStyle(fontSize: 15),
                                          decoration: InputDecoration(
                                            contentPadding: EdgeInsets.zero,
                                            hintText: "优质评论将会被优先展示",
                                            border: OutlineInputBorder(
                                                borderRadius: BorderRadius.circular(10),
                                                borderSide: BorderSide.none),
                                            filled: true,
                                            fillColor: Color(0xFFf0f0f0),
                                          ),
                                        ),
                                      ),
                                      Row(
                                        children: <Widget>[
                                          Padding(
                                            padding: const EdgeInsets.fromLTRB(20.0, 10.0, 13.0, 5.0),
                                            child: Icon(
                                              Icons.photo_size_select_actual_outlined,
                                              size: 26,
                                            ),
                                          ),
                                          Padding(
                                            padding: const EdgeInsets.fromLTRB(13.0, 10.0, 13.0, 5.0),
                                            child: Icon(
                                              Icons.mic_none_outlined,
                                              size: 26,
                                            ),
                                          ),
                                          Padding(
                                            padding: const EdgeInsets.fromLTRB(13.0, 10.0, 13.0, 5.0),
                                            child: Icon(
                                              Icons.sentiment_satisfied_alt_outlined,
                                              size: 26,
                                            ),
                                          ),
                                          Padding(
                                              padding: const EdgeInsets.fromLTRB(80, 10, 0, 0),
                                              child: Container(
                                                height: 35.0,
                                                child: Row(
                                                  children: <Widget>[
                                                    Checkbox(
                                                        value: _checkboxSelected,
                                                        activeColor: Colors.blue[800],
                                                        onChanged: (value) {
                                                          setBottomSheetState(() {
                                                            _checkboxSelected = !_checkboxSelected;
                                                          });
                                                        }),
                                                    Text("同时转发给更多人")
                                                  ],
                                                ),
                                              ))
                                        ],
                                      ),
                                      Divider(
                                        height: 2.0,
                                        indent: 20.0,
                                        color: Color(0xFFd7dadd),
                                        endIndent: 20.0,
                                        thickness: 1.0,
                                      ),
                                      Padding(
                                          padding: const EdgeInsets.fromLTRB(13.0, 0, 13.0, 0),
                                          child: Row(
                                            children: <Widget>[
                                              ButtonTheme(
                                                minWidth: 120.0,
                                                height: 20.0,
                                                child: FlatButton.icon(
                                                  color: Color(0xFFf5f2f2),
                                                  icon: Icon(
                                                    Icons.location_on_outlined,
                                                    color: Colors.blue,
                                                  ),
                                                  label: Text("点击获取位置"),
                                                  shape: RoundedRectangleBorder(
                                                      side: BorderSide.none,
                                                      borderRadius:BorderRadius.all(Radius.circular(50))),
                                                  onPressed: () {},
                                                ),
                                              ),
                                              Padding(
                                                  padding: const EdgeInsets.fromLTRB(160.0, 0, 13.0, 0),
                                                  child: ButtonTheme(
                                                    height: 30.0,
                                                    minWidth: 65.0,
                                                    child: RaisedButton(
                                                      color: Color(0xFFb6d4f0),
                                                      child: Text("发布",
                                                        style: TextStyle(
                                                            color: Colors.white),
                                                      ),
                                                      shape: RoundedRectangleBorder(
                                                          side: BorderSide.none,
                                                          borderRadius: BorderRadius.all(Radius.circular(50))),
                                                      onPressed: () {},
                                                    ),
                                                  ))
                                            ],
                                          ))
                                    ],
                                  ),
                                );
                              });
                            },
                          );
                        },
                      ),
                    ),
                  ),
                  Padding(
                    padding: const EdgeInsets.symmetric(horizontal: 13.0),
                    child: Icon(Icons.chat_bubble_outline, size: 26),
                  ),
                  Padding(
                    padding: const EdgeInsets.symmetric(horizontal: 13.0),
                    child: Icon(Icons.thumb_up_alt_outlined, size: 26),
                  ),
                  Padding(
                    padding: const EdgeInsets.symmetric(horizontal: 13.0),
                    child: Icon(Icons.star_border_outlined, size: 26),
                  ),
                  Padding(
                    padding: const EdgeInsets.symmetric(horizontal: 13.0),
                    child: Icon(Icons.textsms_outlined, size: 26),
                  ),
                ],
              ),
              decoration: BoxDecoration(
                  border: Border(
                      top: BorderSide(width: 1, color: Color(0xFF6e6a6a)))),
            ))
          ],
        ),
      ])),
    );
  }
}
